;
! function() {
	var $ = layui.jquery,
		layer = layui.layer,
		form = layui.form;

	refCode();

	// 点击刷新验证码
	$("#addAdmin_code_img").on("click", function() {
		refCode();
	});

	// 获取验证码
	function refCode() {
		$.ajax({
			url: "/secadminuser/getPictureVerificationCode",
			success: function(result) {
				$("#addAdmin_code_img").prop("src",
					"data:image/jpg;base64," + result.image);
			}
		});
	}

	// 自定义表单验证
	form.verify({
		code: function(value) {
			if(value.length < 6) {
				return "验证码长度不能少于6位";
			}
		}
	});

	form.on("submit(addVersion)", function() {
		$.ajax({
			url: "/appversion/addAppVersion",
			type: "post",
			data: {
				"id": $("#version-id").val(),
				"version":$("#version-version").val(),
				"title": $("#version-title").val(),
				"url": $("#version-url").val(),
				"code": $("#version-code").val(),
				"force" : $("#versionForce").val(),
				"status" : $("#versionStatus").val(),
				"remark" : $("#version-remark").val()
			},
			async: false,
			success: function(result) {
				layer.msg(result.msg);
				if(result.status == 0) {
					location.href='/appVersionList';
				}else{
					$("#version-code").val("");
				}
			}
		});
		return false;
	});
}();